#!/bin/bash
set -e;

# 安装
sudo apt install apt-transport-https ca-certificates dirmngr -y;
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F;
sudo rm -f /etc/apt/sources.list.d/rpimonitor.list;
sudo cp rpimonitor.list /etc/apt/sources.list.d/;


sudo apt update -y;
sudo apt install rpimonitor -y;
sudo apt upgrade -y;
sudo systemctl stop rpimonitor;

echo "######### star config watchdog ##########"
sudo cp daemon.conf /etc/rpimonitor/;
sudo cp -r template /etc/rpimonitor/;
sudo cp /usr/share/rpimonitor/web/addons/top3/top3.cron /etc/cron.d/top3;





echo "########## config finish ##########"
# 重启服务器
echo "########## start service ##########"
sudo systemctl start rpimonitor;
sudo systemctl enable rpimonitor;
sudo /etc/init.d/rpimonitor update;
echo "########## start finished ##########"
